package chapter8;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class IteratorErrorTest {
    public static void main(String[] args) {
        Collection books = new HashSet();
        books.add("轻量级JavaEE企业应用实战");
        books.add("疯狂Java讲义");
        books.add("疯狂Android讲义");
        Iterator it = books.iterator();
        while (it.hasNext()) {
            String book = (String) it.next();
            if(book.equals("疯狂Java讲义"));
            //迭代过程中不允许修改集合中的元素，只可通过Iterator提供的remove来删除上一个迭代的元素
            books.remove(book);
        }
    }
}
